package xdu.lz.stage4_atomic.chapter6_aomicxxxFieldUpdater;

import java.util.concurrent.atomic.AtomicReferenceFieldUpdater;

/**
 * Created at 2019/10/17 0017 下午 8:54
 */



public class ReferenceFiledUpdater {

    private volatile Integer a;

    private volatile int  b;

    public static void main(String[] args) {
        ReferenceFiledUpdater test = new ReferenceFiledUpdater();
        AtomicReferenceFieldUpdater<ReferenceFiledUpdater,Integer> updater =
                AtomicReferenceFieldUpdater.newUpdater(ReferenceFiledUpdater.class,Integer.class,"a");

        updater.getAndSet(test,1);

        System.out.println(test.a);

    }
}
